'\" te
.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright 2020 Joyent, Inc.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
.\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
.TH SVCADM 8 "May 11, 2020"
.SH NAME
svcadm \- manipulate service instances
.SH SYNOPSIS
.nf
\fB/usr/sbin/svcadm\fR [\fB-S state\fR] [\fB-v\fR] [\fB-Z\fR | \fB-z\fR \fIzone\fR] enable [\fB-rst\fR]
     [{\fIFMRI\fR | \fIpattern\fR}...]
.fi

.LP
.nf
\fB/usr/sbin/svcadm\fR [\fB-S state\fR] [\fB-v\fR] [\fB-Z\fR | \fB-z\fR \fIzone\fR] disable
     [\fB-c\fR \fIcomment\fR] [\fB-st\fR] [{\fIFMRI\fR | \fIpattern\fR}...]
.fi

.LP
.nf
\fB/usr/sbin/svcadm\fR [\fB-S state\fR] [\fB-v\fR] [\fB-Z\fR | \fB-z\fR \fIzone\fR] restart [\fB-d\fR]
     [{\fIFMRI\fR | \fIpattern\fR}...]
.fi

.LP
.nf
\fB/usr/sbin/svcadm\fR [\fB-S state\fR] [\fB-v\fR] [\fB-Z\fR | \fB-z\fR \fIzone\fR] refresh
     [{\fIFMRI\fR | \fIpattern\fR}...]
.fi

.LP
.nf
\fB/usr/sbin/svcadm\fR [\fB-S state\fR] [\fB-v\fR] [\fB-Z\fR | \fB-z\fR \fIzone\fR] clear
     [{\fIFMRI\fR | \fIpattern\fR}...]
.fi

.LP
.nf
\fB/usr/sbin/svcadm\fR [\fB-S state\fR] [\fB-v\fR] [\fB-Z\fR | \fB-z\fR \fIzone\fR] mark [\fB-It] \fIinstance_state\fR
     [{\fIFMRI\fR | \fIpattern\fR}...]
.fi

.LP
.nf
\fB/usr/sbin/svcadm\fR [\fB-v\fR] milestone [\fB-d\fR] \fImilestone_FMRI\fR
.fi

.SH DESCRIPTION
\fBsvcadm\fR issues requests for actions on services executing within the
service management facility (see \fBsmf\fR(7)). Actions for a service are
carried out by its assigned service restarter agent. The default service
restarter is \fBsvc.startd\fR (see \fBsvc.startd\fR(8)).
.SH OPTIONS
The following options are supported:
.sp
.ne 2
.na
\fB-S\fR \fIstate\fR
.ad
.RS 20n
For the subcommands which normally operate on explicit \fIFMRI\fRs or an
\fIFMRI\fR pattern, the \fB-S\fR option can be used to select all \fIFMRI\fRs
in the given state.
.RE

.sp
.ne 2
.na
\fB\fB-v\fR\fR
.ad
.RS 20n
Print actions verbosely to standard output.
.RE

.sp
.ne 2
.na
\fB-Z\fR
.ad
.RS 20n
Administer services in all zones.  This option is only applicable
from the global zone, see \fBzones\fR(7).
.RE

.sp
.ne 2
.na
\fB-z\fR \fIzone\fR
.ad
.RS 20n
Administer services in the specified zone.  This option is only applicable
from the global zone, see \fBzones\fR(7).
.RE

.SH SUBCOMMANDS
.SS "Common Operations"
The subcommands listed below are used during the typical administration of a
service instance.
.sp
.LP
For subcommands taking one or more operands, if the operand specifies a service
(instead of a service instance), and that service has only a single instance,
\fBsvcadm\fR operates on that instance. If an abbreviated \fIFMRI\fR (a fault
management resource identifier) matches more than one service or instance, a
warning message is displayed and that operand is ignored.
If a pattern matches more than one service or instance, the subcommand is
applied to all matches. See \fBsmf\fR(7).
.sp
.LP
In the case that the service has more than one instance, \fBsvcadm\fR return a
non-zero exit status.
.sp
.ne 2
.na
\fB\fBenable\fR \fB[\fR\fB-rst\fR\fB]\fR {\fIFMRI\fR | \fIpattern\fR}...\fR
.ad
.sp .6
.RS 4n
Enables the service instances specified by the operands. For each service
instance, the assigned restarter will try to bring it to the online state. This
action requires permission to modify the "general" property group of the
service instance (see \fBsmf_security\fR(7)).
.sp
If the \fB-r\fR option is specified, \fBsvcadm\fR enables each service instance
and recursively enables its dependencies.
.sp
If the \fB-s\fR option is specified, \fBsvcadm\fR enables each service instance
and then waits for each service instance to enter the \fBonline\fR or
\fBdegraded\fR state. \fBsvcadm\fR will return early if it determines that the
service cannot reach these states without administrator intervention.
.sp
If the \fB-t\fR option is specified, \fBsvcadm\fR temporarily enables each
service instance. Temporary enable only lasts until reboot. This action
requires permission to modify the "restarter_actions" property group of the
service instance (see \fBsmf_security\fR(7)). By default, \fBenable\fR is
persistent across reboot.
.RE

.sp
.ne 2
.na
\fB\fBdisable\fR [\fB-c\fR \fIcomment\fR] [\fB-st\fR] {\fIFMRI\fR | \fIpattern\fR}...\fR
.ad
.sp .6
.RS 4n
Disables the service instance specified by the operands. For each service
instance, the assigned restarter will try to bring it to the disabled state.
This action requires permission to modify the "general" property group of the
service instance (see \fBsmf_security\fR(7)).
.sp
If the \fB-s\fR option is specified, \fBsvcadm\fR disables each service
instance and then waits for each service instance to enter the disabled state.
\fBsvcadm\fR will return early if it determines that the service cannot reach
this state without administrator intervention.
.sp
If the \fB-t\fR option is specified, \fBsvcadm\fR temporarily disables each
service instance. Temporary disable only lasts until reboot. This action
requires permission to modify the "restarter_actions" property group of the
service instance (see \fBsmf_security\fR(7)). By default, \fBdisable\fR is
persistent across reboot.
.sp
If the \fB-c\fR option is specified, the given free-form comment is recorded
in the (temporary) service configuration under the \fBgeneral/comment\fR
property.  This can serve as an administrator reason for disabling the service,
and is reported by \fBsvcs\fR(1).
.RE

.sp
.ne 2
.na
\fB\fBrestart\fR [\fB-d\fR] {\fIFMRI\fR | \fIpattern\fR}...\fR
.ad
.sp .6
.RS 4n
Requests that the service instances specified by the operands be restarted.
This action requires permission to modify the "restarter_actions" property
group of the service instance (see \fBsmf_security\fR(7)).
.sp
This subcommand can restart only those services that are in the online or
degraded states, as those states are defined in \fBsmf\fR(7).
.sp
If the \fB-d\fR option is specified, the restarter sends a \fBSIGABRT\fR to all
members of the contract, which should cause a core dump, before restarting
the service.
.RE

.sp
.ne 2
.na
\fB\fBrefresh\fR {\fIFMRI\fR | \fIpattern\fR}...\fR
.ad
.sp .6
.RS 4n
For each service instance specified by the operands, requests that the assigned
restarter update the service's running configuration snapshot with the values
from the current configuration. Some of these values take effect immediately
(for example, dependency changes). Other values do not take effect until the
next service \fBrestart\fR. See the restarter and service documentation for
more information.
.sp
If the service is managed by \fBsvc.startd\fR(8), the \fBrefresh\fR method
will be invoked if it exists to request the service reread its own
configuration. For other restarters, see the restarter documentation.
.sp
This action requires permission to modify the "restarter_actions" property
group of the service instance (see \fBsmf_security\fR(7)).
.RE

.sp
.ne 2
.na
\fB\fBclear\fR {\fIFMRI\fR | \fIpattern\fR}...\fR
.ad
.sp .6
.RS 4n
For each service instance specified by the operands, if the instance is in the
\fBmaintenance\fR state, signal to the assigned restarter that the service has
been repaired. If the instance is in the \fBdegraded\fR state, request that the
assigned restarter take the service to the \fBonline\fR state. This action
requires permission to modify the "restarter_actions" property group of the
service instance (see \fBsmf_security\fR(7)).
.RE

.SS "Exceptional Operations"
The following subcommands are used for service development and temporary
administrative manipulation.
.sp
.ne 2
.na
\fB\fBmark [\fR\fB-It\fR\fB]\fR \fIinstance_state\fR {\fIFMRI\fR |
\fIpattern\fR}...\fR
.ad
.sp .6
.RS 4n
If \fIinstance_state\fR is "maintenance", then for each service specified by
the operands, \fBsvcadm\fR requests that the assigned restarter place the
service in the \fBmaintenance\fR state. See \fBsvc.startd\fR(8) and
\fBinetd\fR(8) for a detailed description of the actions taken for each
restarter.
.sp
If \fIinstance_state\fR is "degraded", then for services specified by the
operands in the online state, \fBsvcadm\fR requests that the restarters
assigned to the services move them into the \fBdegraded\fR state.
.sp
If the \fB-I\fR option is specified, the request is flagged as immediate.
.sp
The \fB-t\fR option is only valid for maintenance requests. When this option is
specified, the request is flagged as temporary, and its effect will only last
until the next reboot.
.RE

.sp
.ne 2
.na
\fB\fBmilestone\fR [\fB-d\fR] \fImilestone_FMRI\fR\fR
.ad
.sp .6
.RS 4n
If \fImilestone_FMRI\fR is the keyword "none", all services other than the
master restarter, \fBsvc:/system/svc/restarter:default\fR, will be temporarily
disabled.
.sp
If \fImilestone_FMRI\fR is the keyword "all", temporary enable and disable
requests for all services will be nullified.
.sp
If \fImilestone_FMRI\fR is one of the following:
.sp
.in +2
.nf
svc:/milestone/single-user:default
svc:/milestone/multi-user:default
svc:/milestone/multi-user-server:default
.fi
.in -2
.sp

then temporary enable and disable requests for the indicated service and all
services it depends on (directly or indirectly) will be nullified. All other
services will be temporarily disabled.
.sp
Changing the system's current milestone with the "milestone" subcommand will
not change the current run level of the system. To change the system's run
level, invoke \fB/sbin/init\fR directly.
.sp
This action requires permission to modify the "options_ovr" property group of
the \fBsvc:/system/svc/restarter:default\fR service instance (see
\fBsmf_security\fR(7)).
.sp
The \fB-d\fR option immediately changes the milestone to the requested
milestone, as above. Additionally, it makes the specified milestone the default
boot milestone, which persists across reboot. The default milestone is defined
by the \fBoptions/milestone\fR property on the master restarter,
\fBsvc:/system/svc/restarter:default\fR. If this property is absent, "all" is
the default. This action requires permission to modify the "options" property
group of the \fBsvc:/system/svc/restarter:default\fR service instance (see
\fBsmf_security\fR(7)).
.RE

.SS "Operands"
The following operands are supported:
.sp
.ne 2
.na
\fB\fIFMRI\fR\fR
.ad
.RS 11n
An \fIFMRI\fR that specifies one or more instances. \fIFMRI\fRs can be
abbreviated by specifying the instance name, or the trailing portion of the
service name. For example, given the \fIFMRI\fR:
.sp
.in +2
.nf
svc:/network/smtp:sendmail
.fi
.in -2
.sp

All the following are valid abbreviations:
.sp
.in +2
.nf
sendmail
:sendmail
smtp
smtp:sendmail
network/smtp
.fi
.in -2
.sp

While the following are invalid:
.sp
.in +2
.nf
mail
network
network/smt
.fi
.in -2
.sp

If the \fIFMRI\fR specifies a service, then the command applies to all
instances of that service. Abbreviated forms of \fIFMRI\fRs are unstable, and
should not be used in scripts or other permanent tools.
.RE

.sp
.ne 2
.na
\fB\fIpattern\fR\fR
.ad
.RS 11n
A pattern that is matched against the \fIFMRIs\fR of service instances
according to the "globbing" rules described by \fBfnmatch\fR(7). If the pattern
does not begin with "svc:", then "svc:/" is prepended.
.RE

.sp
.LP
If an abbreviated \fIFMRI\fR matches more than one service, a warning message
is displayed and that operand is ignored.
If a pattern matches more than one service or instance, the subcommand is
applied to all matches.
.SH EXAMPLES
\fBExample 1 \fRRestarting a Service Instance
.sp
.LP
The following command restarts the \fBNFS\fR server. The full \fIFMRI\fR for
the default service instance is: \fBsvc:/network/nfs/server:default\fR

.sp
.LP
However, you can abbreviate the full \fIFMRI\fR as follows:

.sp
.in +2
.nf
# svcadm restart nfs/server
.fi
.in -2
.sp

.LP
\fBExample 2 \fRDisabling a service
.sp
.LP
The following command synchronously disables a service, using an abbreviated
\fIFMRI\fR, and recording a ticket ID as the administrative reason:

.sp
.in +2
.nf
$ svcadm disable -c "OPS-1000" -s http
.fi
.in -2
.sp

.LP
\fBExample 3 \fREnabling an Instance and Its Dependent Instances
.sp
.LP
The following command enables the \fBfoo:bar\fR instance, and all instances on
which it depends:

.sp
.in +2
.nf
$ svcadm enable -r foo:bar
.fi
.in -2
.sp

.LP
\fBExample 4 \fRSynchronously enabling an instance
.sp
.LP
The following command enables the \fBfoo:bar\fR instance. The command will not
return until the instance comes online or \fBsvcadm\fR determines it is not
possible for the service to come online.

.sp
.in +2
.nf
$ svcadm enable -s foo:bar
.fi
.in -2
.sp

.LP
\fBExample 5 \fRRestricting and Restoring the Running Services
.sp
.LP
The following command restricts the running services to single user mode:

.sp
.in +2
.nf
# svcadm milestone milestone/single-user
.fi
.in -2
.sp

.sp
.LP
The following command restores the running services:

.sp
.in +2
.nf
# svcadm milestone all
.fi
.in -2
.sp

.SH EXIT STATUS
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 5n
Successful completion.
.RE

.sp
.ne 2
.na
\fB\fB1\fR\fR
.ad
.RS 5n
A fatal error occurred. One or more error messages are displayed on standard
error.
.RE

.sp
.ne 2
.na
\fB\fB2\fR\fR
.ad
.RS 5n
Invalid command line options were specified.
.RE

.sp
.ne 2
.na
\fB\fB3\fR\fR
.ad
.RS 5n
\fBsvcadm\fR determined that a service instance that it was waiting for could
not reach the desired state without administrator intervention due to a problem
with the service instance itself.
.RE

.sp
.ne 2
.na
\fB\fB4\fR\fR
.ad
.RS 5n
\fBsvcadm\fR determined that a service instance that it was waiting for could
not reach the desired state without administrator intervention due to a problem
with the service's dependencies.
.RE

.SH ATTRIBUTES
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	See below.
.TE

.sp
.LP
The interactive output is Uncommitted. The invocation and non-interactive
output are Committed.
.SH SEE ALSO
.BR svcprop (1),
.BR svcs (1),
.BR libscf (3LIB),
.BR contract (5),
.BR attributes (7),
.BR smf (7),
.BR smf_security (7),
.BR zones (7),
.BR inetd (8),
.BR init (8),
.BR svc.startd (8),
.BR svccfg (8)
.SH NOTES
The amount of time \fBsvcadm\fR will spend waiting for services and their
dependencies to change state is implicitly limited by their method timeouts.
For example, a service using the default restarter whose start method hangs
will be transitioned to the maintenance state when its timeout expires.
\fBsvcadm\fR will then consider it impossible for this service to come online
without administrator intervention.
.sp
.LP
Attempts to synchronously enable a service which depends (directly or
indirectly) on a file may fail with an exit status indicating that dependencies
are unsatisfied if the caller does not have the privileges necessary to search
the directory containing the file. This limitation may be removed in a future
release.
